package com.example.a2032.db.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.example.a2032.entity.PPGMeasureData;

import java.util.List;

@Dao
public interface PPGDataDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(PPGMeasureData heartRateData);

    @Query("select * from ppgdata")
    LiveData<List<PPGMeasureData>> loadAllHeartRate();

    @Query("select * from ppgdata where date >= :lastUploadDate and dataType =:dataType ORDER BY date DESC")
    List<PPGMeasureData> getLastPPGData(String lastUploadDate, int dataType);
    @Query("select * from ppgdata where dataType =:dataType ORDER BY date DESC")
    LiveData<PPGMeasureData> getLastPPGData(int dataType);

    @Query("select * from ppgdata where date > :lastUploadDate ORDER BY date DESC")
    List<PPGMeasureData> getLastPPGData(String lastUploadDate);

    @Query("select * from ppgdata ORDER BY date DESC")
    List<PPGMeasureData> getLastPPGData();


    @Update
    void updateHeartRateData(PPGMeasureData heartRateData);


}
